using System;
using L=Science.Physics.GeneralPhysics;

namespace Serway.Chapter09
{
	/// <summary>
	/// Example06: Carry Collision Insurance!
	/// An 1,800 kg car stopped at a traffic light is struck 
	/// from the rear by a 900 kg car, and the two become entangled, 
	/// moving along the same path as that of the 20.0 m/s before 
	/// the collision, what is the velocity of the entangled 
	/// cars after the collision?
	/// v_f = 6.67 m/s
	/// </summary>
	public class Example06
	{
		public Example06()
		{
		}
		private string result;
		public string Result
		{
			get{return result;}
		}
		public void Compute()
		{
			L.Mass m1 = new L.Mass();
			m1.kg = 900.0;
			L.Mass m12 = new L.Mass();
			m12.kg = 1800.0+900.0;
			L.Velocity vi = new L.Velocity();
			vi.X = 20.0;
			L.Velocity vf = new L.Velocity();
			L.Momentum[] pi = new L.Momentum[1];
			pi[0] = new L.Momentum(m1,vi);
			L.Momentum[] pf = new L.Momentum[1];
			pf[0] = new L.Momentum(m12,vf);
			pf[0].XVariableQ = true;
			L.FundamentalLaw.MomentumConservation(pi,pf);
			vf.X = pf[0].X/m12.kg;
			result += Convert.ToString(vf.X);
		}
	}
}
